package com.yan;

import com.yan.bo.RequestInfo;
import com.yan.service.ConsoleReporter;
import com.yan.service.EmailReporter;
import com.yan.storage.MetricsStorage;
import com.yan.storage.impl.RedisMetricsStorage;
import com.yan.web.MetricsCollector;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.Date;

/**
 * @author yanheng
 * @data 2020/1/16 17:47
 */
@SpringBootApplication
public class InterIvokeV2Application {
    public static void main(String[] args) {
//        SpringApplication.run(InterIvokeV2Application.class, args);
        MetricsStorage storage = new RedisMetricsStorage();
        ConsoleReporter reporter = new ConsoleReporter(storage);
        reporter.startRepeatedReport(10, 10);

//        EmailReporter emailReporter = new EmailReporter(storage);
//        emailReporter.addToAddress("wangzheng@xzg.com");
//        emailReporter.startDailyReport();
        MetricsCollector collector = new MetricsCollector(storage);
        collector.recordRequest(new RequestInfo("register", 123, System.currentTimeMillis()));
        collector.recordRequest(new RequestInfo("register", 223, System.currentTimeMillis()));
        collector.recordRequest(new RequestInfo("register", 323, System.currentTimeMillis()));
        collector.recordRequest(new RequestInfo("login", 23, System.currentTimeMillis()));
        collector.recordRequest(new RequestInfo("login", 1223, System.currentTimeMillis()));
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
